package com;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

import com.google.gson.JsonObject;

/**
 * @author Xue ShuWen
 * @date 2023/5/31 11:04
 */
@WebServlet("/login")
public class Loginservlet extends HttpServlet{
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        JsonObject jsonObejct = JsonConvert.JsonChange(req);
        String uname = jsonObejct.get("username").getAsString();
        String upassword = jsonObejct.get("password").getAsString();
        System.out.println(uname+upassword);
        UserDaoImpl userDao = new UserDaoImpl();
        try {
            PrintWriter out = resp.getWriter();
            out.println(userDao.queryUser(uname,upassword));
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }

    }
}
